<?php
namespace App\Http\Controllers\Business;

use App\Models\User;
use Illuminate\Support\Facades\Auth;

class UserModule {
    //登录
    public static function login($phone, $password) {
        if(!$phone || !$password) {
            return ['status'=>'failed', 'message'=>'请输入手机号和密码'];
        }
        $user = User::where('phone', $phone)->where('password', $password )->first();
        if(!$user) {
            return ['status'=>'failed', 'message'=>'没有该账号或密码错误'];
        }
        if($user->status == 0) {
            return ['status'=>'failed', 'message'=>'该账号已被禁用，请联系管理员'];
        }
        return ['status'=>'success', 'data'=>['user_id'=>$user->id]];
    }
}
?>
